﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EBAYVN.DOMAIN;
namespace EBAYVN.DAO
{
    public class ChiTietTinhNangLoaiSanPhamDao
    {
        private readonly EBAYVNDOMAINDataContext _db;
        public ChiTietTinhNangLoaiSanPhamDao()
        {
            _db = new EBAYVNDOMAINDataContext();
        }
        public List<CTLOAISP> GetList()
        {
            return _db.CTLOAISPs.Where(p=>p.ISSHOW.HasValue && p.ISSHOW.Value).OrderBy(p => p.NHOMTINHNANG.TENNHOMTN).ToList();
        }
        public List<CTLOAISP> GetListByNhomTinhNang(List<NHOMTINHNANG> manhomtinhnanglist)
        {
            var listmanhomtt = (from p in manhomtinhnanglist
                                select p.ID);
            return _db.CTLOAISPs.Where(p => p.ISSHOW.HasValue && p.ISSHOW.Value && listmanhomtt.Contains((int)p.MANHOMTINHNANG)).OrderBy(p => p.NHOMTINHNANG.TENNHOMTN).ToList();
        }
        public List<CTLOAISP> GetListByLoaiSanPham(string maloaisanpham)
        {
            return _db.CTLOAISPs.Where(p => p.ISSHOW.HasValue && p.ISSHOW.Value && p.MALOAISP.Equals(maloaisanpham)).OrderBy(p => p.NHOMTINHNANG.TENNHOMTN).ToList();
        }
    }
}
